import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/404',
      name: '404',
      meta: {
        title: '404',
      },
      component: () => import('../views/404.vue')
    },
    {
      path: '/',
      name: 'index',
      meta: {
        title: '首页',
      },
      component: () => import('../views/Index.vue')
    },
    {
      path: '/translate',
      name: 'translate',
      meta: {
        title: '学习',
      },
      component: () => import('../views/Translate.vue')
    },
    {
      path: '/translateDetail/:type',
      name: 'translateDetail',
      props: true,
      meta: {
        title: '翻译'
      },
      component: () => import('../views/TranslateDetail.vue')
    },
    {
      path: '/mine',
      name: 'mine',
      meta: {
        title: '我的',
      },
      component: () => import('../views/Mine.vue')
    },
    {
      path: '/userInfo',
      name: 'userInfo',
      meta: {
        title: '用户信息',
      },
      component: () => import('../views/UserInfo.vue')
    },
    {
      path: '/healthInfo',
      name: 'healthInfo',
      meta: {
        title: '健康信息',
      },
      component: () => import('../views/HealthInfo.vue')
    },
    {
      path:'/schedule',
      name: 'schedule',
      meta: {
        title: '预约旅程',
      },
      component: () => import('../views/Schedule.vue')
    },
    {
      path: '/map',
      name: 'map',
      meta: {
        title: '地图',
      },
      component: () => import('../views/Map.vue')
    },
    {
      path: '/myPlan',
      name: 'myPlan',
      meta: {
        title: '我的规划',
      },
      component: () => import('../views/MyPlan.vue')
    },
    {
      path: '/about',
      name: 'about',
      meta: {
        title: '关于我们',
      },
      component: () => import('../views/About.vue')
    },
    {
      path: '/contact',
      name: 'contact',
      meta: {
        title: '联系我们'
      },
      component: () => import('../views/Contact.vue')
    },
    {
      path: '/historyTs',
      name: 'historyTs',
      meta: {
        title: '历史翻译'
      },
      component: () => import('../views/HistoryTs.vue')
    }
  ]
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title
    next()
})

export default router
